home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / strategy / vga_card.000 / vga_cardgames-1.3.1.tar / vga_cardgames / spider.h < prev    next >
C/C++ Source or Header  |  1994-06-25  |  3KB  |  107 lines

  1. /*
  2.  * Spider
  3.  *
  4.  * Copyright (C) Evan Harris, 1991, 1993, 1994
  5.  *
  6.  * Permission is granted to freely redistribute and modify this code,
  7.  * providing the author(s) get credit for having written it.
  8.  */
  9.  
  10. #include "common.h"
  11.  
  12.  
  13. #define FROMSTOCK        -10
  14. #define MOVEOFF            -11
  15. #define TOFOUNDATION        -12
  16. #define COLSPECBASE        -20
  17.  
  18. #define IMPOSSIBLE        0
  19. #define POSSIBLE        1
  20. #define DESIRABLE        2
  21.  
  22.  
  23. #define POSN(col, row)        ((col) * 100 + (row))
  24. #define ROW(pos)        ((pos) % 100)
  25. #define COL(pos)        ((pos) / 100)
  26. #define NOPOSN            -1
  27.  
  28.  
  29. #define SPADES            0
  30. #define CLUBS            1
  31. #define HEARTS            2
  32. #define DIAMONDS        3
  33.  
  34. #define NUMSUITS        8
  35.  
  36. #define CARD(suit, type)    ((suit) * 13 + (type))
  37. #define NOCARD            255
  38. #define SUIT(card)        (((card) % 52) / 13)
  39. #define TYPE(card)        ((card) % 13)
  40. #define ISCARD(card)        ((card) >= 0 && (card) < 104)
  41. #define ISBLACK(card)        (SUIT(card) == SPADES || SUIT(card) == CLUBS)
  42. #define ISRED(card)        (SUIT(card) == HEARTS || SUIT(card) == DIAMONDS)
  43.  
  44. #define NUMCARDS        104
  45. #define COLUMNS            10
  46. #define STOCK            (COLUMNS)
  47. #define PILE            (STOCK + 1)
  48. #define FOUNDATION        (PILE + 1)
  49.  
  50. #define TOHINT(col)        (((col) + 1) << 7)
  51. #define NOHINT(cmd)        ((cmd) & 0x7f)
  52. #define HINT(hint)        (((hint) >> 7) - 1)
  53. #define HASHINT(cmd)        ((cmd) & ~0x7f)
  54.  
  55.  
  56. #define ISCOLSPEC(spec)        ((spec) <= COLSPECBASE)
  57. #define COLTOSPEC(col)        (COLSPECBASE - (col))
  58. #define SPECTOCOL(spec)        (COLSPECBASE - (spec))
  59.  
  60.  
  61. #define ACE            0
  62. #define TWO            1
  63. #define THREE            2
  64. #define FOUR            3
  65. #define FIVE            4
  66. #define SIX            5
  67. #define SEVEN            6
  68. #define EIGHT            7
  69. #define NINE            8
  70. #define TEN            9
  71. #define JACK            10
  72. #define QUEEN            11
  73. #define KING            12
  74.  
  75.  
  76. extern unsigned char    column[COLUMNS];    /* First card of column */
  77. extern unsigned char    stock, pile;        /* First card of stock, pile */
  78. extern short        cards[NUMCARDS];    /* Positions of cards */
  79. extern unsigned char    next[NUMCARDS];        /* Card underneath */
  80. extern unsigned char    hidden[NUMCARDS];    /* Cards which are face down */
  81. extern unsigned char    foundation[NUMSUITS];
  82.  
  83.  
  84. void    main(int, char **);
  85. void    exit(int);
  86.  
  87. void    InitDisplay(int, char **);
  88. void    DisplayColumn(short);
  89. void    DisplayFoundations(void);
  90. void    DisplayStockPile(void);
  91.  
  92. void    Deal(void);
  93.  
  94. short    GetCmd(void);
  95. short    FindDest(short);
  96. short    FindHintedDest(short, short);
  97. void    MakeMove(unsigned char, short);
  98. void    FromStock(void);
  99. void    MoveOff(unsigned char);
  100. short    CanMoveOff(unsigned char);
  101. short    CheckFullTerminatingSuit(unsigned char);
  102. void    AddUndo(unsigned char, unsigned char, short);
  103. void    Undo(void);
  104. void    UndoMove(unsigned char, short, unsigned char);
  105. void    UndoMoveOff(unsigned char, short, unsigned char);
  106. void    UndoFromStock(void);
  107.